<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>用户登录</title>
</head>
<body>
    <h3>用户登录</h3>
    <form action="{% url 'login' %}" method="post">
        {% csrf_token %}
        <p>用户名：<input type="text" name="username" required></p>
        <p>密码：<input type="password" name="password" required></p>
        <p>
            验证码：
            <input type="text" name="valid_number" required style="width: 80px;">
            <img src="{% url 'get_valid_img' %}" id="captcha" alt="验证码" style="cursor: pointer;">
        </p>
        <p><input type="submit" value="登录"></p>
    </form>

    <script>
        // 点击验证码图片时刷新验证码
        document.getElementById("captcha").onclick = function () {
            this.src = "{% url 'get_valid_img' %}?t=" + new Date().getTime();
        };
    </script>
</body>
</html>
